import Cookies from 'js-cookie'
import Config from '@/settings'
const unifiedTokenKey = 'uToken'
const TokenKey = Config.TokenKey

export function getToken(tokeName = TokenKey) {
  return Cookies.get(tokeName)
}

export function setToken({ token, uToken }, rememberMe) {
  if (rememberMe) {
    Cookies.set(TokenKey, token, { expires: Config.tokenCookieExpires })
    Cookies.set(unifiedTokenKey, uToken, { expires: Config.tokenCookieExpires })
  } else {
    Cookies.set(TokenKey, token)
    Cookies.set(unifiedTokenKey, uToken)
  }
}

export function removeToken() {
  Cookies.remove(TokenKey)
  Cookies.remove(unifiedTokenKey)
}

